home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / mac_cs-rcs.vbs < prev    next >
Text File  |  2003-08-13  |  6KB  |  211 lines

  1. ' Caption: CS-RCS|
  2. ' Hint: Component Software RCS|
  3. ' Icon: |
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is mac_cs-rcs.vbs, released Sun, 26 May 2002 10:55:39 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: mac_cs-rcs.vbs,v 1.3.2.5 2003/08/13 00:38:45 neum Exp $
  40.  
  41.  
  42. ' Version 2.2 Macro
  43.  
  44. ' Script to call ComponentSoftware's RCS, if you're not using this implementation
  45. ' from RCS, you may want to access it via the commandline.
  46.  
  47. dim Form
  48. sub Main(dummy)
  49.   dim btnStatus, btnHistory, btnCheckout, btnCheckin, btnExplorer, btnCompare, btnClose
  50.   
  51.   Form = Create("TForm", null, "FindForm")
  52.   with Form
  53.     .Caption = "RCS"
  54.     .Position = "poScreenCenter"
  55.     .BorderStyle = "bsDialog"
  56.     .Width = 100
  57.     .Height = 260
  58. '    .FormStyle = "fsStayOnTop"
  59.   end with
  60.   btnStatus = Create("TButton", Form)
  61.   With btnStatus
  62.     .Parent = Form
  63.     .Caption = "&Status"
  64.     .Default = true
  65.     .Left = 10
  66.     .Top = 10
  67.     .Width = 75
  68.     .Enabled = not IsEmpty(ActiveDocument)
  69.     .Hint = "Show Status for active Document"
  70.     .OnClick = "RcsStatus"
  71.   End With
  72.   btnHistory = Create("TButton", Form)
  73.   With btnHistory
  74.     .Parent = Form
  75.     .Caption = "&History"
  76.     .Left = 10
  77.     .Top = 40
  78.     .Width = 75
  79.     .Enabled = not IsEmpty(ActiveDocument)
  80.     .Hint = "Show History for active Document"
  81.     .OnClick = "RcsHistory"
  82.   End With
  83.   btnCheckout = Create("TButton", Form)
  84.   With btnCheckout
  85.     .Parent = Form
  86.     .Caption = "Check-&out"
  87.     .Left = 10
  88.     .Top = 70
  89.     .Width = 75
  90.     .Enabled = not IsEmpty(ActiveDocument)
  91.     .Hint = "Check out active Document"
  92.     .OnClick = "RcsCheckOut"
  93.   End With
  94.   btnCheckin = Create("TButton", Form)
  95.   With btnCheckin
  96.     .Parent = Form
  97.     .Caption = "Check-&in"
  98.     .Left = 10
  99.     .Top = 100
  100.     .Width = 75
  101.     .Enabled = not IsEmpty(ActiveDocument)
  102.     .Hint = "Check in active Document"
  103.     .OnClick = "RcsCheckIn"
  104.   End With
  105.   btnExplorer = Create("TButton", Form)
  106.   With btnExplorer
  107.     .Parent = Form
  108.     .Caption = "&Explorer"
  109.     .Left = 10
  110.     .Top = 130
  111.     .Width = 75
  112.     .Hint = "Show Document Explorer"
  113.     .OnClick = "RcsExplorer"
  114.   End With
  115.   btnCompare = Create("TButton", Form)
  116.   With btnCompare
  117.     .Parent = Form
  118.     .Caption = "&Compare"
  119.     .Left = 10
  120.     .Top = 160
  121.     .Width = 75
  122.     .Enabled = not IsEmpty(ActiveDocument)
  123.     .Hint = "Compare active Document with the last revision"
  124.     .OnClick = "RcsCompare"
  125.   End With
  126.   btnClose = Create("TButton", Form)
  127.   With btnClose
  128.     .Parent = Form
  129.     .Caption = "C&lose"
  130.     .Cancel = true
  131.     .Left = 10
  132.     .Top = 200
  133.     .Width = 75
  134.     .ModalResult = 1
  135.     .Hint = "Close this Dialog"
  136.   End With
  137.  
  138.   Form.ShowModal
  139.   Form.Free
  140. end sub
  141.  
  142. sub RcsStatus(Sender)
  143.   dim rcsapp
  144.   set rcsapp = CreateObject("Csrcssrv.Application")
  145.   if not IsEmpty(ActiveDocument) then
  146.     rcsapp.StatusEx ActiveDocument.FileName, false
  147.   end if
  148. end sub
  149.  
  150. sub RcsHistory(Sender)
  151.   dim rcsapp
  152.   set rcsapp = CreateObject("Csrcssrv.Application")
  153.   if not IsEmpty(ActiveDocument) then
  154.     rcsapp.History ActiveDocument.FileName
  155.   end if
  156. end sub
  157.  
  158. sub RcsCheckOut(Sender)
  159.   dim rcsapp
  160.   Set rcsapp = CreateObject("Csrcssrv.Application")
  161.   if not IsEmpty(ActiveDocument) then
  162.     rcsapp.CheckOut ActiveDocument.FileName
  163.   end if
  164. end sub
  165.  
  166. sub RcsCheckIn(Sender)
  167.   dim rcsapp
  168.   dim fname
  169.   if not IsEmpty(ActiveDocument) then
  170.     fname = ActiveDocument.FileName
  171.     set rcsapp = CreateObject("Csrcssrv.Application")
  172.     if rcsapp.GetRCSState(fname) = 0 then
  173.       rcsapp.AddToRcs fname
  174.     else
  175.       rcsapp.CheckIn fname
  176.     end if
  177.   end if
  178. end sub
  179.  
  180. sub RcsExplorer(Sender)
  181.   dim rcsapp
  182.   set rcsapp = CreateObject("Csrcssrv.Application")
  183.   rcsapp.PrjExplorer ""
  184. end sub
  185.  
  186. sub RcsCompare(Sender)
  187.   dim fName
  188.   dim rcsapp
  189.   dim objShell
  190.   if not IsEmpty(ActiveDocument) then
  191.     set rcsapp = CreateObject("Csrcssrv.Application")
  192.     fName = rcsapp.GetHeadRevision(ActiveDocument.FileName)
  193.     set rcsapp = nothing
  194.  
  195.     ' The Diff Tool to compare the two files, you may also use the Tool shipped with CS-RCS (CSDiff.exe)
  196.     const DiffExe = "D:\Eigene Dateien\Delphi Projekte\TextDiff\TextDiff.exe"
  197.  
  198.     if fName <> "" and ActiveDocument.FileName <> "" then
  199.       ' Now run a Diff Tool like WinDiff, I use TextDiff (http://rpi.net.au/~ajohnson/delphi/)
  200.       set objShell = CreateObject("WScript.Shell")
  201.       if objShell.Run(IntAddQuotes(DiffExe) & " " & IntAddQuotes(fName) & " " & IntAddQuotes(ActiveDocument.FileName), 1, false) <> 0 then
  202.         MsgBox "Can not start " & DiffExe, 16, "RCS"
  203.       end if
  204.     end if
  205.   end if
  206. end sub
  207.  
  208. private function IntAddQuotes(s)
  209.   IntAddQuotes = Chr(34) & s & Chr(34)
  210. end function
  211.